/** 
 * User: zanel
 * Date: 2005.4.15
 * Time: 12:08:45
 */
package com.generalynx.common.utils;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

public class CollectionUtils {

    public static int[] asArray(Collection collection) {
        int[] array = new int[collection.size()];
        int i = 0;
        for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
            Integer integer = (Integer) iterator.next();
            array[i++] = integer.intValue();
        }
        return array;
    }

    public static Set asSet(int[] array, Set set) {
        for (int i = 0; array != null && i < array.length; i++) {
            set.add(array[i]);
        }
        return set;
    }

}
